﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using TowerDef_s_enseLibrary.game;

namespace TowerDef_s_enseLibrary.tower
{
    public class Bullet : Sprite
    {   
        #region variables

        private int _age;
        private int _speed;

        private int _damage;
        /// <summary>
        /// Get the _damage of a bullet
        /// </summary>
        public int Damage
        {
            get { return _damage; }
        }

        /// <summary>
        /// Return boolean of 
        /// </summary>
        /// <returns>Return true if bullet is death</returns>
        public bool IsDead()
        {
            return _age > 100;
        }

        #endregion variables

        #region functions

        /// <summary>
        /// Create a new Bullet
        /// </summary>
        /// <param name="texture">The bullet Texture</param>
        /// <param name="position">The position of the bullet</param>
        /// <param name="velocity">The velocity of the bullet</param>
        /// <param name="speed">The _speed of a bullet</param>
        /// <param name="damage">The _damage of a bullet</param>
        public Bullet(Texture2D texture, Vector2 position, Vector2 velocity, int speed, int damage) : base(texture, position)
        {
            this.rotation = rotation;
            this._damage = damage;
            this._speed = speed;
            this.velocity = velocity * speed;
        }

        /// <summary>
        /// Create a new Bullet
        /// </summary>
        /// <param name="texture">The bullet Texture</param>
        /// <param name="position">The position of the bullet</param>
        /// <param name="rotation">The rotation of the bullet</param>
        /// <param name="speed">The _speed of a bullet</param>
        /// <param name="damage">The _damage of a bullet</param>
        public Bullet(Texture2D texture, Vector2 position, float rotation, int speed, int damage) : base(texture, position)
        {
            this.rotation = rotation;
            this._damage = damage;
            this._speed = speed;
            velocity = Vector2.Transform(new Vector2(0, -speed), Matrix.CreateRotationZ(rotation));
        }

        /// <summary>
        /// Kill a bullet
        /// </summary>
        public void Kill()
        {
            this._age = 200;
        }

        /// <summary>
        /// Set rotation of a bullet
        /// </summary>
        /// <param name="value">The rotation value</param>
        public void SetRotation(float value)
        {
            rotation = value;
            velocity = Vector2.Transform(new Vector2(0, -_speed), Matrix.CreateRotationZ(rotation));
        }

        /// <summary>
        /// Updates the current bullet
        /// </summary>
        /// <param name="gameTime">The current game time</param>
        public override void Update(GameTime gameTime)
        {
            _age++;
            position += velocity;
            base.Update(gameTime);
        }

        #endregion functions

        #region events



        #endregion events
    }
}
